package com.cn.laoluobase.controller.demo;

import com.cn.laoluobase.config.MyPath;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/yaml")
public class GetYaml {
    @Value("${my-path.oss}")
    private String osPath;

    @Resource
    private Environment environment;

    @Resource
    private MyPath myPath;

    @GetMapping("/demo2")
    public String yamlDemo2 (){
        // MyPath 是一个配置类，需要ConfigurationProperties、setter.
        return myPath.getOss();
    };

    @GetMapping("/demo3")
    public String yamlDemo3 (){
        // environment 是系统自带的环境配置类
        String fileStr = environment.getProperty("my-path.file");
        System.out.println("/demo3:"+fileStr);

        return fileStr;
    }


}
